package agency.web.app.domain;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;


@Entity
@Table(name = "trip")
public class Trip {

	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "TRIP_ID")
	private long tripID;
	
	@OneToMany(cascade = CascadeType.ALL)
    @JoinColumn(name = "USER_ID")
	private List<User> clients;
	
	@Column (name = "DEPART_DATE")
	private Date departDate;
	
	@Column (name = "RETURN_DATE")
	private Date returnDate;
	
	@Column (name = "TOTAL_PRICE")
	private int totalPrice;
	
	@ManyToOne(targetEntity=Tour.class, fetch=FetchType. LAZY)
	@JoinColumn(name = "TOUR_ID")
	private Tour tour;
	
	public Trip(){}
	
	public Trip( User client, Date dd, Date rd, int price, Tour tour){
		
		clients.add(client);
		this.departDate = dd;
		this.returnDate = rd;
		this.totalPrice = price;
		this.tour = tour;
	}
	
	public long getTripID() {
		return tripID;
	}
	public void setTripID(long tripID) {
		this.tripID = tripID;
	}
	
		
	public List<User> getClients() {
		return clients;
	}

	public void setClients(List<User> clients) {
		this.clients = clients;
	}


	

	public Date getDepartDate() {
		return departDate;
	}
	public void setDepartDate(Date departDate) {
		this.departDate = departDate;
	}
	public Date getReturnDate() {
		return returnDate;
	}
	public void setReturnDate(Date returnDate) {
		this.returnDate = returnDate;
	}
	public int getTotalPrice() {
		return totalPrice;
	}
	public void setTotalPrice(int totalPrice) {
		this.totalPrice = totalPrice;
	}
	public Tour getTour() {
		return tour;
	}
	public void setTour(Tour tour) {
		this.tour = tour;
	}
	
	
}
